package com.guli.edu.controller;


import com.guli.commonUtils.R;
import com.guli.edu.entity.StatisticsDaily;
import com.guli.edu.service.impl.StatisticsDailyServiceImpl;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author zxc
 * @since 2023-04-28
 */
@ApiModel(value = "网站统计日数据模块")
@RestController
@RequestMapping("/edu/statistics")
//@CrossOrigin
public class StatisticsDailyController {
    @Autowired
    private StatisticsDailyServiceImpl statisticsDailyService;

    @ApiOperation(value = "获取每日的会员注册数")
    @GetMapping("getStatisticsByDay/{day}")
    public R getStatisticsByDay(@PathVariable String day){
        StatisticsDaily statisticsDaily =  statisticsDailyService.getStatisticsByDay(day);
        return R.ok().data("StatisticsDaily" , statisticsDaily);
    }

    @ApiOperation(value = "获取图表所需要的数据")
    @GetMapping("getChartData/{type}/{begin}/{end}")
    public R getChartData(
            @ApiParam(name = "type" , value = "所要查询的数据类型" ,required = true)
            @PathVariable String type,

            @ApiParam(name = "begin" , value = "起始时间" , required = true)
            @PathVariable String begin,

            @ApiParam(name = "end" , value = "结束时间" , required = true)
            @PathVariable String end){
        Map<String , Object> map = statisticsDailyService.getChartData(type , begin , end);
        return R.ok().data(map);
    }
}

